﻿using CPPEI.ETL.Domain.TaskRuntime;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace CPPEI.ETL.TestApp
{
    class TestJs
    {
        private static EventWaitHandle s_handler = new EventWaitHandle(false, EventResetMode.ManualReset);
        public static void Test()
        {

            //for (int index = 0; index < 5; index++)
            //{
            //    TaskPool.ActualRun("1", Guid.NewGuid());
            //}
            for (int index = 0; index < 30; index++)
            {
                Thread thread = new Thread(Running);
                thread.Start(index);
            }
            s_handler.Set();
            //Thread.Sleep(10);

            //for (int r = 0; r < 20; r++ )
            //{
            //    for (int index = 0; index < 5; index++)
            //    {
            //        Thread thread = new Thread(Running);
            //        thread.Start();
            //    }
            //    Thread.Sleep(10);
            //}
        }
        private static void Running(object id)
        {
            int intId = (int)id;
            s_handler.WaitOne();
            RTParameterContext context = new RTParameterContext();
            context.Open();

            string value3 = context.Run("DateTime.Now().ToString(\"yyyy-MM-dd\")");
            string value32 = context.Run("DateTime.Now().AddDays(-10).ToString(\"yyyy-MM-dd\")");

            Console.WriteLine(intId.ToString() +"===" + value3 +"|||"+ value32);

            context.Close();
        }
    }
}
